package o;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import com.huawei.appgallery.serverreqkit.api.listener.IServerCallBack;
import com.huawei.gamebox.plugin.gameservice.bean.GameInfo;
import com.huawei.gamebox.plugin.gameservice.bean.GetGameBuoyEntryInfoResultResp;
import com.huawei.gamebox.plugin.gameservice.bean.GetUserMsgResp;
import com.huawei.gamebox.plugin.gameservice.bean.PlayerInfo;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant.KeyAndValue;
import o.faa.a;
import org.json.JSONException;
import org.json.JSONObject;

public class ezj implements IServerCallBack {
    String ˊ;
    GameInfo ˋ;
    protected Context ˎ;
    ccm ˏ;
    fad ॱ;

    ezj(String str, fad o_fad) {
        this.ॱ = o_fad;
        this.ˊ = str;
    }

    public void ˎ(GameInfo gameInfo, String str) {
        if (dof.ॱ(str)) {
            ResponseBean o_eyr = new eyr();
            o_eyr.setRtnCode_(1);
            ˎ(o_eyr);
            return;
        }
        PlayerInfo playerInfo = new PlayerInfo();
        try {
            String str2;
            playerInfo.fromJson(new JSONObject(str));
            playerInfo.ˋ(ezq.ˏ().ˏ(gameInfo.getPackageName()));
            playerInfo.ˏ(ezq.ˏ().ˊ(gameInfo.getPackageName()));
            playerInfo.ˎ(playerInfo.ˊ() == null ? "" : playerInfo.ˊ());
            playerInfo.ॱ(playerInfo.ˎ() == null ? "" : playerInfo.ˎ());
            playerInfo.ˊ(playerInfo.ˋ() == null ? "" : playerInfo.ˋ());
            if (playerInfo.ʽ() == null) {
                str2 = "";
            } else {
                str2 = playerInfo.ʽ();
            }
            playerInfo.ॱॱ(str2);
        } catch (Throwable e) {
            Logger.ˋ("BaseGssApiProvider", "addPlayerInfo JSONException", e);
        } catch (Throwable e2) {
            Logger.ˋ("BaseGssApiProvider", "addPlayerInfo IllegalArgumentException", e2);
        } catch (Throwable e22) {
            Logger.ˋ("BaseGssApiProvider", "addPlayerInfo IllegalAccessException", e22);
        } catch (Throwable e222) {
            Logger.ˋ("BaseGssApiProvider", "addPlayerInfo InstantiationException", e222);
        } catch (Throwable e2222) {
            Logger.ˋ("BaseGssApiProvider", "addPlayerInfo ClassNotFoundException", e2222);
        }
        eyd ˎ = eyq.ˎ(gameInfo, playerInfo, ezq.ˏ().ˏ(gameInfo.getPackageName()), ezq.ˏ().ˊ(gameInfo.getPackageName()));
        if (ˎ != null) {
            fbh.ˋ(ˎ, this);
        }
    }

    void ˎ(GameInfo gameInfo, IServerCallBack iServerCallBack) {
        fbh.ˋ(eyw.ˎ(gameInfo, this.ˏ, ezq.ˏ().ˏ(gameInfo.getPackageName()), ezq.ˏ().ˊ(gameInfo.getPackageName())), iServerCallBack);
    }

    public void ˊ(GameInfo gameInfo, String str) {
        int i;
        Throwable e;
        if (dof.ॱ(str)) {
            ResponseBean getUserMsgResp = new GetUserMsgResp();
            getUserMsgResp.setRtnCode_(1);
            ˎ(getUserMsgResp);
            return;
        }
        String str2 = "";
        try {
            JSONObject jSONObject = new JSONObject(str);
            i = jSONObject.getInt("isReadMsg");
            try {
                str2 = jSONObject.getString("readRed");
            } catch (JSONException e2) {
                e = e2;
                Logger.ˋ("BaseGssApiProvider", "getUserMsg", e);
                fbh.ˋ(eza.ॱ(gameInfo, this.ˏ, i, str2), this);
            }
        } catch (Throwable e3) {
            Throwable th = e3;
            i = 0;
            e = th;
            Logger.ˋ("BaseGssApiProvider", "getUserMsg", e);
            fbh.ˋ(eza.ॱ(gameInfo, this.ˏ, i, str2), this);
        }
        fbh.ˋ(eza.ॱ(gameInfo, this.ˏ, i, str2), this);
    }

    public void ॱ(Context context, GameInfo gameInfo) {
        eyd ˏ = eyy.ˏ(gameInfo, this.ˏ);
        ezr.ˎ().ˋ(this.ˊ);
        this.ˎ = context;
        this.ˋ = gameInfo;
        fbh.ˋ(ˏ, this);
    }

    public void ˋ(GameInfo gameInfo) {
        cfw.ˎ(eyx.ˎ(gameInfo, this.ˏ), this);
    }

    public void ˎ(GameInfo gameInfo) {
        faa o_faa = new faa(gameInfo);
        o_faa.ˎ(new a(this) {
            final /* synthetic */ ezj ˏ;

            {
                this.ˏ = r1;
            }

            public void ˎ(Boolean bool) {
                if (this.ˏ.ॱ != null) {
                    GetGameBuoyEntryInfoResultResp getGameBuoyEntryInfoResultResp = new GetGameBuoyEntryInfoResultResp();
                    getGameBuoyEntryInfoResultResp.ˏ(bool.booleanValue());
                    try {
                        this.ˏ.ॱ.ˋ(this.ˏ.ˊ, getGameBuoyEntryInfoResultResp.toJson());
                    } catch (Throwable e) {
                        Logger.ˋ("BaseGssApiProvider", "send the response to client exception", e);
                    } catch (Throwable e2) {
                        Logger.ˋ("BaseGssApiProvider", "To buoy entry result json failed", e2);
                    } catch (Throwable e22) {
                        Logger.ˋ("BaseGssApiProvider", "To buoy entry result json failed", e22);
                    }
                }
            }
        });
        o_faa.ॱ();
    }

    public void ˋ() {
        fbh.ˋ(new fbq(), this);
    }

    void ˎ(ResponseBean responseBean) {
        if (this.ॱ != null) {
            if (responseBean != null) {
                try {
                    String toJson = responseBean.toJson();
                    if (responseBean.getResponseCode() != 0) {
                        JSONObject jSONObject = new JSONObject(toJson);
                        jSONObject.put("responseCode", responseBean.getResponseCode());
                        toJson = jSONObject.toString();
                    }
                    this.ॱ.ˋ(this.ˊ, toJson);
                    return;
                } catch (Throwable e) {
                    Logger.ˋ("BaseGssApiProvider", "send the response to client exception", e);
                    return;
                } catch (Throwable e2) {
                    Logger.ˋ("BaseGssApiProvider", "send the response to client exception", e2);
                    return;
                } catch (Throwable e22) {
                    Logger.ˋ("BaseGssApiProvider", "send the response to client exception", e22);
                    return;
                } catch (Throwable e222) {
                    Logger.ˋ("BaseGssApiProvider", "send the response to client exception", e222);
                    return;
                }
            }
            this.ॱ.ˋ(this.ˊ, null);
        }
    }

    void ˋ(BaseRequest o_cvu, ResponseBean responseBean) {
        if (responseBean != null && (o_cvu instanceof eyu)) {
            eyu o_eyu = (eyu) o_cvu;
            String ˊ = o_eyu.ˊ();
            String valueOf = String.valueOf(System.currentTimeMillis());
            int responseCode = responseBean.getResponseCode();
            String str = null;
            String method_ = o_eyu.getMethod_() == null ? "" : o_eyu.getMethod_();
            String ˎ = o_eyu.ˎ() == null ? "" : o_eyu.ˎ();
            String ˏ = o_eyu.ˏ() == null ? "" : o_eyu.ˏ();
            String ʼ = o_eyu.ʼ() == null ? "" : o_eyu.ʼ();
            switch (responseCode) {
                case 0:
                    if (responseBean.getRtnCode_() != 0) {
                        str = ezk.ॱ(method_ + "_" + 1);
                        break;
                    }
                    break;
                case 2:
                    str = ezk.ॱ(method_ + "_" + 2);
                    break;
                case 3:
                    str = ezk.ॱ(method_ + "_" + 3);
                    break;
                default:
                    str = ezk.ॱ(method_ + "_" + 4);
                    break;
            }
            Context ˋ = ContentManager.getInstant().getContext();
            try {
                String str2 = "15070106";
                StringBuilder append = new StringBuilder(256).append(KeyAndValue.NUMBER_01).append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR).append(ezq.ˏ().ˎ(ˎ)).append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR).append(ˎ).append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR).append(ˏ).append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR).append(ʼ).append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR).append(method_).append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR).append(ˊ).append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR).append(valueOf).append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR).append(Build.MODEL).append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR).append(doo.ʼ(ˋ)).append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR).append(ॱ(ˋ));
                if (str != null) {
                    append.append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR).append(str);
                }
                dgh.ॱ(ContentManager.getInstant().getContext(), str2, append.toString());
            } catch (Throwable e) {
                Logger.ˋ("BaseGssApiProvider", "add Hianalytics Log", e);
            }
        }
    }

    private String ॱ(Context context) {
        String str = "";
        int ʼ = doo.ʼ(context);
        if (!(ʼ == 0 || ʼ == 1)) {
            NetworkInfo activeNetworkInfo = ((ConnectivityManager) context.getSystemService("connectivity")).getActiveNetworkInfo();
            if (activeNetworkInfo != null) {
                return activeNetworkInfo.getExtraInfo();
            }
        }
        return str;
    }

    public void prePostResult(BaseRequest o_cvu, ResponseBean responseBean) {
    }

    public void notifyResult(BaseRequest o_cvu, ResponseBean responseBean) {
        ˎ(responseBean);
    }
}
